package cn.ecut.servlet;

import cn.ecut.services.ApplyServices;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/apply/deal")
public class DealApplyServlet extends HttpServlet {

    public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        int applyid = -1;
        ApplyServices aservice = new ApplyServices();
        if (request.getParameter("passId") != null) {
            applyid = (Integer.parseInt(request.getParameter("passId")));
            aservice.updateApplyState(applyid);
        } else if (request.getParameter("failId") != null) {
            applyid = (Integer.parseInt(request.getParameter("failId")));
            aservice.updateApplyState2(applyid);
        }else if (request.getParameter("deleteId") != null) {
            applyid = (Integer.parseInt(request.getParameter("deleteId")));
            aservice.deleteApply(applyid);
        }
        response.sendRedirect("/applymanage.jsp");
    }

    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }

}
